﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class BaseInfoMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!CMSUser.Current.IsLogin)
            {
                Response.Redirect("~/login.aspx");
            }
        }
        catch (Exception)
        {
            Response.Redirect("~/login.aspx");
        }

        this.ASPxNavBar1.Groups.Clear();
        this.ASPxNavBar1.Font.Size = FontUnit.Parse("10pt");
        if (Cache["NavBarList"] == null)
        {
            using (DAL.CMSDALDataContext DataContext = new DAL.CMSDALDataContext())
            {
                Cache["NavBarList"] = DataContext.BI_FFunctions.ToList();
            }
        }
        List<DAL.BI_FFunctions> list = Cache["NavBarList"] as List<DAL.BI_FFunctions>;
        List<DAL.BI_FFunctions> groupList = list.Where(o => o.ParentID == "0").ToList();
        foreach (DAL.BI_FFunctions group in groupList)
        {
            DevExpress.Web.ASPxNavBar.NavBarGroup Nbgroup = this.ASPxNavBar1.Groups.Add(group.Description, group.FucnctionID);
            List<DAL.BI_FFunctions> itemList = list.Where(o => o.ParentID == group.FucnctionID).ToList();
            foreach (DAL.BI_FFunctions item in itemList)
            {
                //判断人员是否有此权限
                if (CMSUser.Current.CheckActionAllow(item.FucnctionID))
                {
                    Nbgroup.Items.Add(item.Description, item.FucnctionID, string.Empty, item.Url);
                }
            }
        }
    }
}
